#include <QDebug>

#include "commentitemview.h"
#include "ui_commentitemview.h"

CommentItemView::CommentItemView(Comment *comment, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CommentItemView)
{
    ui->setupUi(this);
    this->comment = comment;

    init();
}

CommentItemView::~CommentItemView()
{
    delete ui;
    delete comment;
}

void CommentItemView::paintEvent(QPaintEvent *)
{
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

void CommentItemView::init()
{
    ui->userIcon->setImageUrl(comment->getOwnerIcon());
    ui->commentOwner->setText(comment->getOwner());
    ui->commentDesc->setText(comment->getCommentText());
    qDebug() << "Comment Text: " << comment->getCommentText();
    ui->commentDesc->setToolTip(comment->getCommentText());
    ui->commentTime->setText(comment->getTimeCreated());
}
